package Bidostar_Case;

import Bidostar_Data.Baseinfo;
import Bidostar_Page.LoginPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class LoginCase extends Baseinfo
{
    WebDriver driver = new FirefoxDriver();

    long StartTime = System.currentTimeMillis();

    @Test(priority = 1)
    public void LoginTest_URL1() throws Exception
    {
        long StartTime = System.currentTimeMillis();
        driver.get(Baseinfo.URL1);

        driver.manage().window().maximize();

        LoginPage lp = new LoginPage(driver);
        if (lp.Login())
        {
            logger.info("case执行成功，登录成功");
        } else if (driver.getCurrentUrl().contains("login.html"))
        {
            if (lp.LoginBySecond())
            {
                logger.info("============case执行成功，登录成功============");
            }
        } else
        {
            logger.warn("case执行失败，登录成功");
        }
    }

    @Test(priority = 2)
    public void LoginTest_URL2() throws Exception
    {
        driver.get(Baseinfo.URL2);

        driver.manage().window().maximize();

        LoginPage lp = new LoginPage(driver);
        if (lp.Login())
        {
            logger.info("case执行成功，登录成功");
        } else if (driver.getCurrentUrl().contains("login.html"))
        {
            if (lp.LoginBySecond())
            {
                logger.info("============case执行成功，登录成功============");
            }
        } else
        {
            logger.warn("case执行失败，登录成功");
        }
    }

    @Test(priority = 3)
    public void LoginTest_URL3() throws Exception
    {
        driver.get(Baseinfo.URL3);

        driver.manage().window().maximize();

        LoginPage lp = new LoginPage(driver);
        if (lp.Login())
        {
            logger.info("case执行成功，登录成功");
        } else if (driver.getCurrentUrl().contains("login.html"))
        {
            if (lp.LoginBySecond())
            {
                logger.info("============case执行成功，登录成功============");
            }
        } else
        {
            logger.warn("case执行失败，登录成功");
        }
        long EndTime = System.currentTimeMillis();

        logger.info("运行时长为：" + (EndTime - StartTime) / 1000 + "S");
    }
}
